package com.example.samplelistener;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

public class SampleDialog extends Dialog
{
	public interface OnWidthChangedListener
	{
		//幅を渡す抽象メソッド
		void onWidthChanged(int width);
	}
	
	private OnWidthChangedListener onWidthListener;
	
	public void setOnWidthListener(OnWidthChangedListener listener)
	{
		this.onWidthListener=listener;
	}

	public SampleDialog(Context context) 
	{
		super(context);
	}

	public SampleDialog(Context context, int theme)
	{
		super(context, theme);
	}

	public SampleDialog(Context context, boolean cancelable,OnCancelListener cancelListener)
	{
		super(context, cancelable, cancelListener);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.contents_dialog);
		
		SeekBar sb=(SeekBar)findViewById(R.id.dia_seek);
		sb.setOnSeekBarChangeListener(new SeekBarListener());
	}
	
	public class SeekBarListener implements OnSeekBarChangeListener
	{
		@Override
		public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
		{
			// TODO 自動生成されたメソッド・スタブ
			
		}

		@Override
		public void onStartTrackingTouch(SeekBar seekBar)
		{
			// TODO 自動生成されたメソッド・スタブ
			
		}

		@Override
		public void onStopTrackingTouch(SeekBar seekBar)
		{
			if(onWidthListener!=null)
			{
				onWidthListener.onWidthChanged(seekBar.getProgress());
			}
			dismiss();
		}
	}
}
